package com.wolfeyes.framework.springsecurity.encoder;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import com.wolfeyes.common.utils.framework.spring.SpringContextUtils;

/**
 * @title BCryptPasswordEncoder.matches(CharSequence rawPassword, String encodedPassword)
 * @title org.springframework.security.authentication.dao.DaoAuthenticationProvider->
 * @see if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) {(90行)
 * @description 开发环境dev开启免密模式
 * @author yanyljava
 *
 */
public class CustomizeBCryptPasswordEncoder extends BCryptPasswordEncoder {

	@Override
	public boolean matches(CharSequence rawPassword, String encodedPassword) {
		
		if (!"dev".equalsIgnoreCase(SpringContextUtils.getActiveProfile())) {
			return true;
		}
		boolean matcheResult = super.matches(rawPassword, encodedPassword);
		return matcheResult;
	}
}
